<div class="form" id="newAnn">
	<h4 id="frmTitle" align="center">New Announcement </h4>
	<form name="newAnnouncement" method="post" action="/bizbuddy.com/site/class/controller.php" enctype="multipart/form-data">
    	<table>
            <tr>
                <td>Subject </td>
                <td><input type="text" name="subject" size="42" /> </td>
            </tr>
            <tr>
            	<td>Category</td>
                <td>
                	<input type="button" name="category" id="category" onclick="chooseCats();" value="Choose Category"/>
                    <div id="categories">
	                    <div id="chooseCat"></div>
                    	<div id="addCat" colspan="2" align="center">
                        	<input type="button" class="button" id="add" value="New Category"/>
                            <div id="addCategory">
                                <input type='text' id='newwCat'/>
                                <input type='button'class='button' id='btnCat' onclick='newCategory();' value='Add' />
                        	</div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
            	<td>Image</td>
                <td><div id="image"></div><input type="file" name="image"/></td>
            </tr>
            <tr>
                <td>Description </td>
                <td><textarea name="description" cols="50" rows="10"></textarea> </td>
            </tr>
            <?php if($adm)
				  { 
			?>
            <tr>
            	<td>Status</td>
                <td>
                	<select name="status">
                    	<option value="0">Non-Approved</option>
                        <option value="1">Approved</option>
                    </select>
                </td>
            </tr>
            <?php
				  }
			?>
            <tr>
	            <td colspan="2" align="center"><input type="button" class="button" onclick="addAnnouncement();" value="Save" /></td>
            </tr>
        </table>
	    <input type="hidden" name="type" value="newAnnouncement" />
        <input type="hidden" id="chosenCats" name="chosenCats" value="" />
        <input type="hidden" id="loadCats"/>
    </form>
</div>
<script>
	$(document).ready(function(){
		$("div#categories").hide();
		$("div#addCategory").hide();
	
		$("input#category").click(function(){
			$("div#categories").slideToggle();
			$("div#chooseCat").load("site/forms/categoryList.php");
		});
		
		$("input#loadCats").click(function(){
			$("div#chooseCat").load("site/forms/categoryList.php");
		});
		
		$("input#chosen").click(function(){
			$("div#chooseCat").slideToggle();
			$("input[type=button]#category").fadeOut();
			$("div#addCat").fadeOut();
		});
	
		$("input#add").click(function(){
			$("div#addCategory").slideToggle();
		});
	});
</script>
<?php
	if($type == 'edit')
	{		
		require_once('c:/wamp/www/bizbuddy.com/site/class/utility.php');
		$post 	= utility::getPost($id,$content_type);
		$post	= $post[0];
	?>
<script type="text/javascript">
	var frm = document.newAnnouncement;
	frm.subject.value 		= "<?php echo $post['name'];?>";
	//must add comma for category to make its javascript work getting cats checked :)
	frm.chosenCats.value 	= "<?php echo $post['category_ids'].',';?>"; 
	document.getElementById("image").innerHTML = "<?php echo '<a href=\"'.$post['image'].'\" target=\"_blank\" title=\"Clik to view image\"><img src=\"'.$post['image'].'\" width=\"100px\" style=\"float:right;\" /></a>';?>Browse to Change Image<br/><br/>";
	frm.description.value 	= "<?php echo $post['description'];?>";
	frm.type.value			= 'editAnnouncement';
	var oldImage 			= document.createElement("input");
	oldImage.name 			= "oldImage";
	oldImage.type			= "hidden";
	oldImage.value			= "<?php echo $post['image'];?>";
	frm.appendChild(oldImage);
	var id		 			= document.createElement("input");
	id.name 				= "id";
	id.type					= "hidden";
	id.value				= "<?php echo $post['id'];?>";
	frm.appendChild(id);
	frm.status.value		= <?php echo $post['status'];?>;
	document.getElementById("frmTitle").innerHTML = 'Update Announcement';
</script>		
	<?php
		}
	?>
